home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1097 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. Path: irisa.fr!usenet
  2. From: jezequel@stormbringer.irisa.fr (Jean-Marc Jezequel)
  3. Newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.c,comp.lang.c++,comp.lang.modula2,comp.lang.modula3,comp.lang.smalltalk
  4. Subject: global variable in Eiffel (was Re: whither style)
  5. Date: 9 Jan 1996 08:48:41 GMT
  6. Organization: Irisa, Rennes (FR)
  7. Sender: jezequel@irisa.fr (Jean-Marc Jezequel)
  8. Distribution: world
  9. Message-ID: <4cta59$h9@news.irisa.fr>
  10. References: <cmanDK7x13.5KM@netcom.com> <30e26364.2569895@news1.wolfe.net> <60SqRiBF3RB@herold.franken.de> <4ct8s9$477@disunms.epfl.ch>
  11. NNTP-Posting-Host: stormbringer.irisa.fr
  12.  
  13. In article <4ct8s9$477@disunms.epfl.ch>, Stephane.Barbey@di.epfl.ch (Stephane Barbey) writes:
  14. >In article <60SqRiBF3RB@herold.franken.de>, jhd@herold.franken.de (Joachim Durchholz) writes:
  15. >: There is definitely no such thing as a global variable in Eiffel.
  16. >: 
  17. >
  18. >What about attributes defined in the classes ANY (and also in HERE in a
  19. >previous version of Eiffel)?
  20.  
  21. Such attributes are not global variables: only they are inherited by all classes
  22. in an Eiffel Universe (not a recommanded thing to do then).
  23.  
  24. But you can *build* global variables if you need them: declare a once function returning
  25. the global variable in the class ANY.
  26. Expl:
  27.  
  28. class ANY
  29.    global_integer: INTEGER_REF is
  30.     -- global variable, i.e. shared by all objects
  31.     once
  32.        !!Result
  33.     end -- global_integer
  34. end -- ANY
  35.  
  36. In Eiffel, this is however seldom useful.
  37.  
  38. More useful is to use the same mecanism to share variables among a few number
  39. of classes.
  40.  
  41.  
  42. -- 
  43. Jean-Marc Jezequel               Tel : +33 99847192         
  44. IRISA/CNRS                       Fax : +33 99847171         
  45. Campus de Beaulieu               e-mail : jezequel@irisa.fr 
  46. F-35042 RENNES (FRANCE)          http://www.irisa.fr/pampa/PROF/jmj.html
  47.